
package com.idealighter.game.personalcenter.manager;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import com.idealighter.game.personalcenter.dto.PlayerBaseInfo;
import com.idealighter.game.personalcenter.message.ResBindEmailMsg;
import com.idealighter.game.personalcenter.message.ResBindPhoneMsg;
import com.idealighter.game.personalcenter.message.ResEnterPersonalCenterMsg;
import com.idealighter.game.personalcenter.message.ResGetUnBindPhoneKeyMsg;
import com.idealighter.game.personalcenter.message.ResMdifyPwdProtectMsg;
import com.idealighter.game.personalcenter.message.ResModifyBankPwdMsg;
import com.idealighter.game.personalcenter.message.ResModifyBaseInfoMsg;
import com.idealighter.game.personalcenter.message.ResModifyGameSettingMsg;
import com.idealighter.game.personalcenter.message.ResModifyLoginPwdMsg;
import com.idealighter.game.personalcenter.message.ResRealNameAuthenticateMsg;
import com.idealighter.game.personalcenter.message.ResUnBindPhoneMsg;
import com.idealighter.game.player.manager.PlayerMsgWriter;
import com.idealighter.game.player.struct.Player;

/**
 * 个人中心消息管理 .
 * 
 * @date 2015年11月12日 下午2:40:43
 *
 */
@Singleton
public class PersonalCenterMsgMgr {

  @Inject
  private PlayerMsgWriter msgWriter;


  /**
   * 发送进入个人中心结果消息 .
   * 
   * @param res 0:成功,1:密码不正确
   */
  public ResEnterPersonalCenterMsg sendEnterPersonalCenterMsg(int res) {
    ResEnterPersonalCenterMsg msg = new ResEnterPersonalCenterMsg();
    msg.setRes(res);
    return msg;
  }

  /**
   * 发送修改玩家基本信息.
   * 
   * @param baseInfo .
   */
  public ResModifyBaseInfoMsg sendModifyBaseInfoMsg(PlayerBaseInfo baseInfo) {
    ResModifyBaseInfoMsg msg = new ResModifyBaseInfoMsg();
    msg.setBaseInfo(baseInfo);
    return msg;
  }

  /**
   * 发送实名验证结果 .
   * 
   * @param player 玩家.
   * @param res 0:成功,1:重复校验,2:姓名格式不对(2-10个汉字),3:身份证格式不对
   */
  public void sendRealNameAuthenticateMsg(Player player, int res) {
    ResRealNameAuthenticateMsg msg = new ResRealNameAuthenticateMsg();
    msg.setRes(res);
    msg.setIdNo(player.getIdcard());
    msg.setName(player.getName());
    msgWriter.writeMsg(player, msg);
  }

  /**
   * 发送修改登录密码结果 .
   * 
   * @param res 0:成功,1:旧密码输入不正确, 2:新密码格式不对
   */
  public ResModifyLoginPwdMsg sendModifyLoginPwdMsg(int res) {
    ResModifyLoginPwdMsg msg = new ResModifyLoginPwdMsg();
    msg.setRes(res);
    return msg;
  }


  /**
   * 发送修改银行密码结果 .
   * 
   * @param player 玩家.
   */
  public ResModifyBankPwdMsg sendModifyBankPwdMsg(Player player) {
    ResModifyBankPwdMsg msg = new ResModifyBankPwdMsg();
    return msg;
  }

  /**
   * 发送绑定手机消息 .
   * 
   * @param phone .
   */
  public ResBindPhoneMsg resBindPhoneMsg(String phone) {
    ResBindPhoneMsg msg = new ResBindPhoneMsg();
    msg.setPhone(phone);
    return msg;
  }

  /**
   * 发送绑定邮箱消息.
   * 
   * @param email .
   */
  public ResBindEmailMsg sendBindEmailMsg(String email) {
    ResBindEmailMsg msg = new ResBindEmailMsg();
    msg.setEmail(email);
    return msg;
  }

  /**
   * 发送解除绑定手机消息 .
   * 
   * @param player 玩家.
   */
  public void sendUnBindPhoneMsg(Player player) {
    ResUnBindPhoneMsg msg = new ResUnBindPhoneMsg();
    msgWriter.writeMsg(player, msg);
  }

  /**
   * 发送修改游戏设置消息 .
   * 
   * @param player 玩家.
   */
  public void sendModifyGameSettingMsg(Player player) {
    ResModifyGameSettingMsg msg = new ResModifyGameSettingMsg();
    msg.setLoginPhoneVerify(player.isLoginPhoneVerify() ? 1 : 0);
    msg.setPlayItemEffect(player.isPlayItemEffect() ? 1 : 0);
    msgWriter.writeMsg(player, msg);
  }

  /**
   * 发送解除获取绑定手机验证码结果 .
   * 
   * @param player 玩家.
   * @param res 0:成功,1:获取验证码时间间隔不足
   */
  public void sendGetUnBindPhoneKeyMsg(Player player, int res, int second) {
    ResGetUnBindPhoneKeyMsg msg = new ResGetUnBindPhoneKeyMsg();
    msg.setRes(res);
    msg.setSecond(60 - second);
    msgWriter.writeMsg(player, msg);
  }

  /**
   * 发送修改密保结果啊消息 .
   * 
   * @param player 玩家.
   */
  public void sendModifyPwdProtectMsg(Player player) {
    ResMdifyPwdProtectMsg msg = new ResMdifyPwdProtectMsg();
    msgWriter.writeMsg(player, msg);
  }
}
